package com.hcbd.tdwt.ui.haige.setting.activity;

import android.annotation.SuppressLint;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;


import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.Constant;
import com.hcbd.tdwt.util.SharedPreferencesUtil;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_send_set_haige)
public class SendSetActivity extends BaseActivity{
    @ViewById
    Button saveBtn;
    @ViewById(R.id.chinese_character_mode)
    RadioButton chineseRb;
    @ViewById(R.id.code_pattern)
    RadioButton codePatternRb;
    @ViewById(R.id.blend_mode)
    RadioButton blendModeRb;
    @ViewById
    RadioGroup modeRG,frequencyPointRG;
    @ViewById
    RadioButton pointTwoRB,pointThreeRB;
    @ViewById
    TextView title;
    SharedPreferencesUtil sp;
    @AfterViews
    protected void init() {
        chineseRb.setTag(Constant.CHINESE_CHAR_MODE);
        codePatternRb.setTag(Constant.CODE_PATTERN);
        blendModeRb.setTag(Constant.BLEND_MODE);
        pointTwoRB.setTag(Constant.POINT_TWO);
        pointThreeRB.setTag(Constant.POINT_THREE);
        sp=new SharedPreferencesUtil(this);
        String mode=sp.getAttribute(Constant.MSG_MODE);
        if(Constant.CHINESE_CHAR_MODE.equals(mode)){
            chineseRb.setChecked(true);
        }else if(Constant.BLEND_MODE.equals(mode)){
            blendModeRb.setChecked(true);
        }else{
            codePatternRb.setChecked(true);
        }
        String point=sp.getAttribute(Constant.SEND_POINT_TYPE);
        if(Constant.POINT_THREE.equals(point)){
            pointThreeRB.setChecked(true);
        }else{
            pointTwoRB.setChecked(true);
        }
        title.setText("发送消息设置");
    }
    @Click
    void saveBtn(){
        RadioButton rb = findViewById(modeRG.getCheckedRadioButtonId());
        sp.addAttribute(Constant.MSG_MODE,rb.getTag().toString());

        RadioButton pointRb = findViewById(frequencyPointRG.getCheckedRadioButtonId());
        sp.addAttribute(Constant.SEND_POINT_TYPE,pointRb.getTag().toString());

        finish();
        toast("保存成功！");
    }

    @Click
    void headLeft(){
        finish();
    }
}